home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / fontutil.6 / fontutil / fontutils-0.6 / limn / output-bzr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-25  |  3.7 KB  |  126 lines

  1. /* output-bzr.c: write the BZR output file.
  2.  
  3. Copyright (C) 1992 Free Software Foundation, Inc.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #include "config.h"
  20.  
  21. #include "bzr.h"
  22. #include "main.h"
  23. #include "output-bzr.h"
  24.  
  25. /* The name of the output file.  (-output-file)  */
  26. string output_name = NULL;
  27.  
  28.  
  29. /* Most of the data is coordinates, so we make changing that convenient.  */
  30. #define POINT_FROM_PIXELS_TO_POINTS(p)                    \
  31.   (p).x = PIXELS_TO_POINTS ((p).x, dpi_real);                \
  32.   (p).y = PIXELS_TO_POINTS ((p).y, dpi_real)
  33.  
  34.  
  35.  
  36. /* Open the output file and write the preamble information.  */
  37.  
  38. void
  39. bzr_start_output (string output_name, bitmap_font_type font)
  40. {
  41.   bzr_preamble_type p;
  42.   string bzr_name = extend_filename (output_name, "bzr");
  43.   
  44.   bzr_open_output_file (bzr_name);
  45.   
  46.   BZR_DESIGN_SIZE (p) = BITMAP_FONT_DESIGN_SIZE (font);
  47.   
  48.   /* We don't need the day of the week in the comment, hence the `+4'.  */
  49.   BZR_COMMENT (p) = concat4 ("limn output ", now () + 4,
  50.                              BITMAP_FONT_COMMENT (font) ? " from " : "",
  51.                              BITMAP_FONT_COMMENT (font));
  52.   
  53.   bzr_put_preamble (p);
  54.   free (bzr_name);
  55. }
  56.  
  57.  
  58.  
  59. /* Write the information for one character.  */
  60.  
  61. void
  62. bzr_output_char (char_info_type c, spline_list_array_type in_splines)
  63. {
  64.   bzr_char_type bzr_char;
  65.   unsigned this_list;
  66.   spline_list_array_type out_splines = new_spline_list_array ();
  67.   real dpi_real = atof (dpi);
  68.   
  69.   CHARCODE (bzr_char) = CHARCODE (c);
  70.   CHAR_SET_WIDTH (bzr_char) = PIXELS_TO_POINTS (CHAR_SET_WIDTH (c), dpi_real);
  71.  
  72.   CHAR_MIN_COL (bzr_char) = PIXELS_TO_POINTS (CHAR_MIN_COL (c), dpi_real);
  73.   CHAR_MAX_COL (bzr_char) = PIXELS_TO_POINTS (CHAR_MAX_COL (c), dpi_real);
  74.   CHAR_MIN_ROW (bzr_char) = PIXELS_TO_POINTS (CHAR_MIN_ROW (c), dpi_real);
  75.   CHAR_MAX_ROW (bzr_char) = PIXELS_TO_POINTS (CHAR_MAX_ROW (c), dpi_real);
  76.  
  77.   /* We have to change all the values in the spline list to be in
  78.      points, instead of pixels.  */
  79.   
  80.   for (this_list = 0; this_list < SPLINE_LIST_ARRAY_LENGTH (in_splines);
  81.        this_list++)
  82.     {
  83.       unsigned this_spline;
  84.       spline_list_type in_list = SPLINE_LIST_ARRAY_ELT (in_splines, this_list);
  85.       spline_list_type out_list = *new_spline_list ();
  86.       
  87.       for (this_spline = 0; this_spline < SPLINE_LIST_LENGTH (in_list);
  88.            this_spline++)
  89.         {
  90.           spline_type s = SPLINE_LIST_ELT (in_list, this_spline);
  91.           
  92.           if (SPLINE_DEGREE (s) == LINEAR)
  93.             {
  94.               POINT_FROM_PIXELS_TO_POINTS (START_POINT (s));
  95.               POINT_FROM_PIXELS_TO_POINTS (END_POINT (s));
  96.             }
  97.           else
  98.             { /* It's a cubic.  */
  99.               POINT_FROM_PIXELS_TO_POINTS (START_POINT (s));
  100.               POINT_FROM_PIXELS_TO_POINTS (CONTROL1 (s));
  101.               POINT_FROM_PIXELS_TO_POINTS (CONTROL2 (s));
  102.               POINT_FROM_PIXELS_TO_POINTS (END_POINT (s));
  103.             }
  104.  
  105.           append_spline (&out_list, s);
  106.         }
  107.       
  108.       append_spline_list (&out_splines, out_list);
  109.     }
  110.     
  111.   BZR_SHAPE (bzr_char) = out_splines;
  112.   
  113.   bzr_put_char (bzr_char);
  114. }
  115.  
  116.  
  117.  
  118. /* Finish off the output file, and close it.  */
  119.  
  120. void
  121. bzr_finish_output ()
  122. {
  123.   bzr_put_postamble ();
  124.   bzr_close_output_file ();
  125. }
  126.